﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace AsyncCallback
{
class FileStreamClient
{
    Byte[] m_Array = new Byte[2000];
    Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.None, 1000, true);
    public void AsyncRead()
    {
        using (stream)
        {
            stream.BeginRead(m_Array, 0, 10, OnMethodCompletion, null);
        }
    }

    void OnMethodCompletion(IAsyncResult asyncResult)
    {
         using (stream)
        {
          int bytesRead =  stream.EndRead(asyncResult);
          Trace.WriteLine("Read Bytes: " + bytesRead);
        }
    }
}
}
